package com.lt.report.controller.common;

import com.lt.report.service.CommonService;
import com.lt.report.util.SelectAjaxDataVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class CommonController {

    @Autowired
    CommonService commonService;

    /**
     * 根据数据字典中的类型Id获取全部基础数据
     * @param typeId
     * @return
     */
    @CrossOrigin
    @GetMapping("getBaseByType")
    public List<SelectAjaxDataVO> getBaseByType(@RequestParam("typeId") String typeId){
        try {
            Map<String,Object> map = new HashMap<>();
            map.put("typeId",typeId);
            List<SelectAjaxDataVO> list =commonService.queryBaseDataByType(map);
            return list;
        }catch (Exception e){
            e.printStackTrace();
            return null;//暫無用戶非法登錄

        }
    }

}
